from cProfile import label
import csv
from signal import pthread_kill
from matplotlib import pyplot as plt
from sklearn.utils import resample
from torch import int64
from paint_filter import picture_filter
from paint_filter import data_filter
from paint_filter import filter_data
from paint_filter import filter_44_48_data

filename_itcopy = 'itcopyhitdata7.csv'
filename_oncopy = 'oncopyhitdata7.csv'


itcopy_hit_probe_time = []
oncopy_hit_probe_time = []
itcopy_hit_data = []
oncopy_hit_data = []

itcopy_count = 1
oncopy_count = 1

with open(filename_itcopy) as f_it:
    reader = csv.reader(f_it)

    try:
        for row in reader:
            hit_time_item = int(row[0])
            hit_data_item = int(row[1])
            itcopy_hit_probe_time.append(hit_time_item)
            itcopy_hit_data.append(hit_data_item)
    except IndexError:
        pass

print (itcopy_hit_probe_time)
print (itcopy_hit_data)
print (len(itcopy_hit_data))



with open(filename_oncopy) as f_on:
    reader = csv.reader(f_on)

    try:
        for row in reader:
            oncopy_time_item = int(row[0])
            hit_data_item = int(row[1])
            oncopy_hit_probe_time.append(oncopy_time_item)
            oncopy_hit_data.append(hit_data_item)
    except IndexError:
        pass

print (oncopy_hit_probe_time)
print (oncopy_hit_data)
print (len(oncopy_hit_data))



# paint the picture

color1 = '#C0504D'
color2 = '#00EEEE'

ax = plt.gca()
ax.set_xlabel('Time(Interval ID)')
ax.set_ylabel('Latency(Cycle)')

plt.scatter(itcopy_hit_probe_time, itcopy_hit_data, marker='*', c=color1, alpha=1, label='itcopy')
plt.scatter(oncopy_hit_probe_time, oncopy_hit_data, marker='^', c=color2, alpha=1, label='oncopy')



plt.legend()
plt.show()
# plt.close()